package com.rdzn.mall.center.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.rdzn.mall.center.entity.PmsProductCategory;
import com.rdzn.mall.center.mapper.PmsProductCategoryMapper;
import com.rdzn.mall.center.service.IPmsProductCategoryService;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: pms_product_category
 * @Author: jeecg-boot
 * @Date:   2020-08-27
 * @Version: V1.0
 */

@Service
public class PmsProductCategoryServiceImpl extends ServiceImpl<PmsProductCategoryMapper, PmsProductCategory> implements IPmsProductCategoryService {

    @Override
    public List<PmsProductCategory> listHome() {
        List<PmsProductCategory> list = list(new LambdaQueryWrapper<PmsProductCategory>()
                .eq(PmsProductCategory::getNavStatus, 1)
                        .eq(PmsProductCategory::getShowStatus, 1)
                        .eq(PmsProductCategory::getParentId, 0)
                        .orderByDesc(PmsProductCategory::getSort)
        );
        return list;
    }

    @Override
    public List<PmsProductCategory> listRoot() {
        List<PmsProductCategory> list = list(new LambdaQueryWrapper<PmsProductCategory>()
//                .eq(PmsProductCategory::getNavStatus, 1)
                .eq(PmsProductCategory::getShowStatus, 1)
                .eq(PmsProductCategory::getParentId, 0)
                .orderByDesc(PmsProductCategory::getSort)
        );
        return list;
    }

    @Override
    public List<PmsProductCategory> listByParentId(Integer parentId) {
        return list(new LambdaQueryWrapper<PmsProductCategory>()
                .eq(PmsProductCategory::getShowStatus, 1)
                .eq(PmsProductCategory::getParentId, parentId)
                .orderByDesc(PmsProductCategory::getSort)
        );
    }
}
